Ext.define('Admin.view.needWater.comSitAnalysis.ComSitAnalysisController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.comSitAnalysisController',
    views: ['Admin.view.needWater.comSitAnalysis.ComSitAnalysis'],
    init: function () {
        var me = this;
        // Ext.getCmp('zhxsfxBtn1').fireEvent('click');
        // me.buildChart();
    },
    buildChart: function () {
        var me = this;
        me.buildzhxsfxChart1();
        me.buildzhxsfxChart2();
        me.buildzhxsfxChart3();
        me.buildzhxsfxChart4();
    },
    buildzhxsfxChart1: function (dom) {
        var me = this;
        var data = {
            title: '来水分析',
            domId: dom.el.id + '-body',
            data: [{
                name: '预报来水',
                data: [60, 90, 140, 100, 78, 43, 35, 30, 33, 34, 37, 45],
                dashStyle: 'dash'
            }, {
                name: '实际来水',
                data: [58, 88, 120, 85]
            }]
        };
        me.chartInit(data.domId, data.title, data.data);
    },
    buildzhxsfxChart2: function (dom) {
        var me = this;
        var data = {
            title: '供水量分析',
            domId: dom.el.id + '-body',
            data: [{
                name: '计划供水',
                data: [null, null, null, 26, 26, 26, 26, 26, 20, 20, 20, 20],
                dashStyle: 'dash'
            }, {
                name: '实际供水',
                data: [26, 26, 26, 26]
            }]
        };
        me.chartInit(data.domId, data.title, data.data);
    },
    buildzhxsfxChart3: function (dom) {
        var me = this;
        var data = {
            title: '水库期末蓄水量分析',
            domId: dom.el.id + '-body',
            data: [{
                name: '计划期末蓄水量',
                data: [160, 160, 160, 170, 170, 165, 140, 110, 100, 90, 85, 95],
                dashStyle: 'dash'
            }, {
                name: '实际期末蓄水量',
                data: [155, 150, 130, 135]
            }, {
                name: '兴利库容',
                data: [null, null, null, null, 170, 170, 170, 170, 170, 170, 170, 170],
                dashStyle: 'dash',
                marker: {
                    radius: 0
                }
            }, {
                name: '农业限制线',
                data: [110, 130, 130, 115, 115, 115, 115, 115, 110, 110, 110, 110],
                dashStyle: 'dash',
                marker: {
                    radius: 0
                }
            }, {
                name: '工业限制线',
                data: [65, 65, 65, 65, 70, 70, 70, 70, 70, 70, 70, 70],
                dashStyle: 'dash',
                marker: {
                    radius: 0
                }
            }]
        };
        me.chartInit(data.domId, data.title, data.data);
    },
    buildzhxsfxChart4: function (dom) {
        var me = this;
        var data = {
            title: '出库断面下泄水量分析',
            domId: dom.el.id + '-body',
            data: [{
                name: '计划下港',
                data: [null, null, null, 85, 85, 60, 60, 60, 40, 40, 40, 40],
                dashStyle: 'dash'
            }, {
                name: '实际下港',
                data: [60, 90, 140, 85]
            }]
        };
        me.chartInit(data.domId, data.title, data.data);
    },
    chartInit: function (domId, title, data) {
        $('#' + domId).highcharts({
            title: {
                text: title
            },
            chart: {
                // marginTop: 20
            },
            xAxis: {
                categories: ['6月', '7月', '8月', '9月', '10月', '11月', '12月', '1月', '2月', '3月', '4月', '5月']
            },
            yAxis: {
                title: {
                    text: '水量/亿m³'
                },
                plotLines: [{
                    value: 0,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '亿m³'
            },
            legend: {
                layout: 'horizontal',
                align: 'center',
                verticalAlign: 'top',
                borderWidth: 0,
                y: 15
            },
            series: data,
            credits: {
                enabled: false
            }
        });
    },
    changeType: function (_this) {
        var me = this;
        me.buildChart();
    }
})
